//
//  MeVC.m
//  CJRailTransport
//
//  Created by Hank on 2017/12/21.
//  Copyright © 2017年 amplity. All rights reserved.
//

#import "MeVC.h"
#import "MeCell.h"
#import "LoadingListVC.h"
#import "HistoryVC.h"

@interface MeVC ()
// 列表数据
@property (strong ,nonatomic)NSMutableArray *listDataArray;

@end

@implementation MeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置导航栏
    [self setNavC];
    // 设置界面属性
    [self setViewAttribute];
    // 设置tableView headView
    [self loadTableHeadView];
    // 注册Cell
    [self registerCells];
    // 设置数据
    [self setData];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
//    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

#pragma mark - 导航栏
- (void)setNavC
{
    self.title = @"我";
    // 设置导航栏颜色
    BasicNavigationController *nVC = (BasicNavigationController *)self.navigationController;
    nVC.themeColor = [UIColor whiteColor];
    nVC.tintColor = [UIColor darkGrayColor];
}

// 设置界面属性
- (void)setViewAttribute
{
    self.view.backgroundColor = [UIColor whiteColor];
}

#pragma mark - tableView headView
// 设置tableView headView
- (void)loadTableHeadView
{
    _myTableView.tableHeaderView = self.tableHeadView;
}

// 注册Cell
- (void)registerCells
{
    UINib *nib = [UINib nibWithNibName:[MeCell reuseIdentifier] bundle:nil];
    [_myTableView registerNib:nib forCellReuseIdentifier:[MeCell reuseIdentifier]];
}

// 设置数据
- (void)setData
{
    NSArray *dataArray = @[@{@"title":@"历史信息",@"image":@"login_userName"},@{@"title":@"装车清单",@"image":@"login_userName"},@{@"title":@"记录修改",@"image":@"login_userName"}];
    _listDataArray = [NSMutableArray arrayWithArray:dataArray];
}

#pragma mark - TableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _listDataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MeCell *cell = [tableView dequeueReusableCellWithIdentifier:[MeCell reuseIdentifier] forIndexPath:indexPath];
    cell.indexPath = indexPath;
    [cell setData:_listDataArray[indexPath.row]];
    return cell;
}
#pragma mark - TableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:{
            HistoryVC *historyVC = [[HistoryVC alloc]init];
            [self.navigationController pushViewController:historyVC animated:YES];
            break;
        }
        case 1:{
            LoadingListVC *loadingListVC = [[LoadingListVC alloc]init];
            [self.navigationController pushViewController:loadingListVC animated:YES];
        }
        case 2:{
            
        }
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
